package org.dna.metronomo.persistence;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * Simple bean to represent an Activity. An Activity is composed by a set of simple
 * job stints.
 * 
 * An activity could be deleted, if it hasn't got any job related, or marked in 
 * state StatusEnum.DELETED
 * 
 * @see org.dna.metronomo.persistence.Activity
 * @see org.dna.metronomo.persistence.StatusEnum
 * */
public class Activity implements Serializable {
	private static final long serialVersionUID = -4735861071294335763L;
	private int id = 0;
	private String name;
	private String description;
	private StatusEnum status = StatusEnum.VALID;
	private List<Job> jobs;
	private Date estimatedStart = new Date();
	private TimePeriod estimatedEffort = new TimePeriod();

	public Activity(String name, String description) {
		this.name = name;
		this.description = description;
	}

	public Activity() {
	}

	public int getId() {
		return id;
	}

	public List<Job> getJobs() {
		return jobs;
	}

	public String getDescription() {
		return description;
	}
	
	public void setDescription(String description) {
		this.description = description;
	}

	public String getName() {
		return name;
	}
	
	public void setName(String name) {
		this.name = name;
	}

	public TimePeriod getEffort() {
		int days = 0;
		int hours = 0;
		int minutes = 0;
		for (Job job : jobs) {
			days += job.getElapsed().getDays();
			hours += job.getElapsed().getHours();
			minutes += job.getElapsed().getMinutes();
		}
		return new TimePeriod(days, hours, minutes);
	}

	public void setEstimatedStart(Date estimatedStart) {
		this.estimatedStart = estimatedStart;
	}

	public Date getEstimatedStart() {
		return estimatedStart;
	}
	
	public TimePeriod getEstimatedEffort() {
		return estimatedEffort;
	}

	public void setEstimatedEffort(TimePeriod estimatedEffort) {
		this.estimatedEffort = estimatedEffort;
	}
}
